<?php
function timeFormat($format){
	$format = strftime($format);
	$script = "$('result').setHTML('$format')"
		. ".effect('background-color').start('9f9', 'fff');";
	return MooResponse::script($script);
}
require "mooremote.php";
$moo = new MooRemote();
// custom function
$moo->registerFunction("timeFormat");
// native function
$moo->registerFunction("md5");
$moo->processRequest();
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>MooRemote - Demo</title>
	<link  href="style.css" type="text/css" rel="stylesheet" />
	<script src="mootools.patched.js" type="text/javascript"></script>
	<script src="mooremote.js" type="text/javascript"></script>
	<?php echo $moo->getJavascript(); ?>
	<script type="text/javascript">
		window.addEvent("domready", function(){
			$("timeformat").addEvent("click", function(e){
				new Event(e).preventDefault();
				var input = $("input").getValue();
				mooRemote.timeFormat(input);
			});
			$("md5").addEvent("click", function(e){
				new Event(e).preventDefault();
				var input = $("input").getValue();
				mooRemote.md5(input).callback(myCallback);
			})
		});
		function myCallback(md5){
			$('result').setHTML(md5);
		};
	</script>
</head>
<body>
	<form action="#">
		<h1>MooRemote</h1>
		<input type="text" id="input" value="%m/%d/%y - %H:%M:%S" />
		<button id="timeformat">strftime</button>
		<button id="md5">MD5</button>

		<p class="last">
			Result: <span id="result">&nbsp;</span>
		</p>
	</form>
	<div class="source">
		<h2>Source</h2>
		<?php highlight_file(__FILE__); ?>
	</div>
</body>
</html>